﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Web.Mvc;
using System.ComponentModel;


namespace DotaStrategy.Models
{
    [Bind(Exclude="Id")]
    public class Heroe
    {
        [ScaffoldColumn(false)]
        [HiddenInput(DisplayValue=true)]
        [DisplayName("Heroe Number (id)")]
        public int Id { get; set; }

        [Required(ErrorMessage="Seguro que no tiene nombre???")]
        public string Name { get; set; }

        [Compare("Name", ErrorMessage = "Repeti el nombre")]
        public string NameCopy { get; set; }

        [Range(1,25,ErrorMessage="Cuanto nivel queres que tenga?! (entre 1 y 25)")]
        [Required(ErrorMessage="Nivel null? ver primer item de la charla")]
        public int Level { get; set; }

        List<Item> Items { get; set; }
    }
     
    [Bind(Exclude = "Id")]
    public class Item {

        [ScaffoldColumn(false)]
        [DisplayName("Item Id")]
        public int Id { get; set; }

        [Remote("Mayority","Items",ErrorMessage="El número debe ser mayor a 2")]
        public int Number { get; set; }

        [AllowHtml]
        [Required(ErrorMessage="Seguro que no tiene nombre???")]
        public string Name { get; set; }
     }

    public class MyDotaConnection:DbContext  { 
        public DbSet<Heroe> Heroes {get;set;}
        public DbSet<Item> Items { get; set; }

        protected override void OnModelCreating(System.Data.Entity.ModelConfiguration.ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Heroe>().Ignore(h => h.NameCopy);
        }
    }
}